package codeCreate.restfulAPICreate.util;

import java.text.SimpleDateFormat;
import java.util.Date;

public class TextCodeCreateUtil {
    private static String PARENTTHESES_PREFIX = "(";
    private static String PARENTTHESES_SUFFIX = ")";
    private static String BRACKET_PREFIX = "[";
    private static String BRACKET_SUFFIX = "]";
    private static String BLANK = " ";
    private static String COLON = ":";

    public static String createLogMessage(String methodName, String message) {
        StringBuffer stringBuffer = new StringBuffer(nowTimeFormat());
        stringBuffer.append(" 方法").append(BRACKET_PREFIX).append(methodName).append(BRACKET_SUFFIX).append("出现错误，")
                .append("错误信息：").append(message);
        return stringBuffer.toString();
    }

    private static String nowTimeFormat() {
        SimpleDateFormat format = new SimpleDateFormat("YYYY-MM-dd hh:mm:ss");
        return format.format(new Date());
    }

    public static String createRequireId(String projectNumber, String requireNumber) {
        return new StringBuffer(projectNumber).append("03").append(requireNumber).toString();
    }

    public static void main(String[] args) {
        StackTraceElement[] stacks = new Throwable().getStackTrace();
        System.out.println(Thread.currentThread().getStackTrace()[1].getClassName());
        System.out.println(Thread.currentThread().getStackTrace()[1].getMethodName());
    }
}
